package com.matt.foundation.vo.liveRecord;

import com.matt.domain.record.LiveRecord;
import com.matt.foundation.constant.LiveRecordConstant;
import lombok.Data;

import java.util.List;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2017/8/3
 * *******************************
 */
@Data
public class BaseInfoVo {
    private String id;

    private String name;

    private String imgUrl;

    private Integer todayImgNum = 0;

    private Integer todayVideoNum = 0;

    private Integer weekImgNum = 0;

    private Integer weekVideoNum = 0;

    private Integer classesNum = 0;

    private Integer totalImgNum=0;

    private Integer totalVideoNum=0;

    private String areaName;

    private Integer loginNum;

    private Integer lastLoginDays;

    public static BaseInfoVo of(String staffId, String name, String imgUrl, List<LiveRecord> daysInfo, List<LiveRecord> weekInfo,  List<LiveRecord> totalInfo, String areaName, Integer classesNum, Integer loginNum, Integer lastLoginDays) {
        BaseInfoVo vo = new BaseInfoVo();
        vo.setId(staffId);
        vo.setName(name);
        vo.setImgUrl(imgUrl);
        daysInfo.forEach(o -> {
            if (LiveRecordConstant.MediaType.IMG.codeOf() == o.getMediaType())
                vo.setTodayImgNum(vo.getTodayImgNum() + 1);
            else
                vo.setTodayVideoNum(vo.getTodayVideoNum() + 1);
        });
        weekInfo.forEach(o -> {
            if (LiveRecordConstant.MediaType.IMG.codeOf() == o.getMediaType())
                vo.setWeekImgNum(vo.getWeekImgNum() + 1);
            else
                vo.setWeekVideoNum(vo.getWeekVideoNum() + 1);
        });

        totalInfo.forEach(o -> {
            if (LiveRecordConstant.MediaType.IMG.codeOf() == o.getMediaType())
                vo.setTotalImgNum(vo.getTotalImgNum() + 1);
            else
                vo.setTotalVideoNum(vo.getTotalVideoNum() + 1);
        });
        vo.setClassesNum(classesNum);
        vo.setAreaName(areaName);
        vo.setLoginNum(loginNum);
        vo.setLastLoginDays(lastLoginDays);
        return vo;
    }
}
